//
//  LTLOrigina.m
//  WeiBo
//
//  Created by Apple_Lzzy46 on 16/10/19.
//  Copyright © 2016年 LTL. All rights reserved.
//

#import "LTLOrigina.h"
#import "LTLframeModel.h"
#import "LTLPhone.h"
#import "LTLpictureView.h"
#import "LTLPhotoView.h"
@interface LTLOrigina ()
///头像
@property(nonatomic , weak)UIImageView *icon;
///名字
@property(nonatomic , weak)UILabel *name;
///会员
@property(nonatomic , weak)LTLPhotoView *Member;
///VIP
@property(nonatomic , weak)UIImageView *VIP;
///时间
@property(nonatomic , weak)UILabel *time;
///来源
@property(nonatomic , weak)UILabel *source;
///正文
@property(nonatomic , weak)UILabel *text;
///配图
//@property(nonatomic , weak)UICollectionView *pic_urls;
@property(nonatomic , weak)LTLpictureView *pic_urls;
//
//@property(nonatomic, strong)LTLframeModel *frameModel;
@end

@implementation LTLOrigina
static NSString *ID = @"pictureViewCell";
-(instancetype)initWithFrame:(CGRect)frame
{
    if ((self = [super initWithFrame:frame]) != nil ) {
        
        [self layoutUI];
        
    }
    return self;
}
#pragma mark -布局添加 UI
//布局
-(void)layoutUI
{
    //头像
    UIImageView *icon = [[UIImageView alloc]init];
    icon.layer.masksToBounds = YES;
    //名字
    UILabel *name = [[UILabel alloc]init];
//    name.font = [UIFont systemFontOfSize:18];
    //认证
    LTLPhotoView *Member = [[LTLPhotoView alloc]init];
    //VIP
    UIImageView *VIP = [[UIImageView alloc]init];
    //时间
    UILabel *time = [[UILabel alloc]init];
    time.font = [UIFont systemFontOfSize:12];
    time.textColor = [UIColor grayColor];
    //来源
    UILabel *source = [[UILabel alloc]init];
    source.font = [UIFont systemFontOfSize:12];
    source.textColor = [UIColor grayColor];
    
    //正文
    UILabel *text = [[UILabel alloc]init];
    text.numberOfLines = 0;
    
    LTLpictureView *pictureView = [[LTLpictureView alloc]init];
    
    [self addSubview:icon];
    [self addSubview:name];
    [self addSubview:Member];
    [self addSubview:VIP];
    [self addSubview:time];
    [self addSubview:source];
    [self addSubview:text];
    [self addSubview:pictureView];
    
    self.icon = icon;
    self.name = name;
    self.Member = Member;
    self.time = time;
    self.source = source;
    self.text = text;
    self.pic_urls = pictureView;
    self.VIP = VIP;
//    NSLog(@"1");
}
#pragma mark -设置数据
/**
 设置数据

 @param frameModel 数据
 */
-(void)setFrameModel:(LTLframeModel *)frameModel
{
    _frameModel = frameModel;
    //设置各控件数据
    [self.icon sd_setImageWithURL:[NSURL URLWithString:frameModel.model.user.profile_image_url] placeholderImage:[UIImage imageNamed:@"avatar_default_big"]];
    //
    self.name.text = frameModel.model.user.name;
    
    self.Member.verifiedType = _frameModel.model.user.verified_type;
    //判断是否是VIP会员
//    NSLog(@"%@",_frameModel.model.user.mbrank);
    
    if (![_frameModel.model.user.mbrank  isEqual: @"0"]) {
        
        self.VIP.image = [UIImage imageNamed:[NSString stringWithFormat:@"common_icon_membership_level%@",_frameModel.model.user.mbrank]];
        
    } else {
        self.VIP.image = [UIImage imageNamed:@"common_icon_membership_expired"];
    }
    
    self.time.text = frameModel.model.created_at;
    
    self.source.text = frameModel.model.source;
    
    self.text.text = frameModel.model.text;
    
    self.pic_urls.phone = _frameModel.model.pic_urls;
    ///
    [self layout];
}
/**
 布局
 */
-(void)layout
{
    //重新设置Frame
    self.icon.frame = self.frameModel.iconFrame;
    self.icon.layer.cornerRadius = self.icon.width / 2.0;
    self.name.frame = self.frameModel.nameFrame;
    self.Member.frame = self.frameModel.vFrame;
    self.time.frame = self.frameModel.created_atFrame;
    self.source.frame = self.frameModel.sourceFrame;
    self.text.frame = self.frameModel.textFrame;
    self.pic_urls.frame = self.frameModel.pictureFrame;
    self.VIP.frame = self.frameModel.vipFrame;
    
}

@end
